// 节流（立即执行）
function throttle(fn, delay, immediate = true) {
	let timer = null
	return function (...args) {
	  if (!timer) {
		timer = setTimeout(() => {
		  timer = null
		  !immediate && fn.apply(this, args)
		}, delay)
		immediate && fn.apply(this, args)
	  }
	}
}

module.exports = {
	throttle: throttle
}